package com.finstate.dao.impl;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.finstate.dao.UserDao;
import com.finstate.domain.User;

@Repository
public class UserDaoImpl implements UserDao {

	@Autowired
	private SessionFactory session;
	
	public void addUser(User user) {
		session.getCurrentSession().save(user);
	}

	public User getUserByName(String username) {
		return (User)session.getCurrentSession().createQuery("from User user where user.username like :username")
				.setString("username", username).uniqueResult();
	}

}
